package com.shop.cereshop.app.param.index;

import cn.hutool.core.util.StrUtil;
import com.shop.cereshop.commons.config.RsaProperties;
import com.shop.cereshop.commons.utils.RsaUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;

/**
 * @description: TODO 
 * @author lx
 * @date 2025/8/1 12:34
 * @version 1.0
 */
@Data
@Accessors(chain = true)
@ApiModel(value = "LoginDTO", description = "登录请求DTO")
public class PwdLoginDTO {

    @ApiModelProperty(value = "手机号/uuid(需要加密)", required = true)
    private String phone;

    @ApiModelProperty(value = "密码(需要加密)", required = true)
    private String password;

    @ApiModelProperty(value = "验证码")
    private String verificationCode;

    public PwdLoginDTO decrypt() throws Exception {
        PwdLoginDTO res = this;
        if (StrUtil.isNotBlank(this.password)) {
            res.setPassword(RsaUtils.decryptByPrivateKey(RsaProperties.privateKey,this.password));
        }
        res.setPhone(RsaUtils.decryptByPrivateKey(RsaProperties.privateKey,this.phone));
        return res;
    }
}
